﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace TByte.XnaHelper.GameObjects
{

    public class SpriteGameObject : GameObject
    {
        #region Fields
        protected float rotation;
        protected SpriteEffects spriteEffects;
        protected float layerDepth;
        protected float scale;
        private Vector2 origin;
        #endregion

        #region Methods
        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(texture, Position, null, color, rotation, origin, scale, spriteEffects, layerDepth);

            base.Draw(spriteBatch);
        }
        #endregion

        #region Constructors
        public SpriteGameObject(Texture2D texture, Vector2 position, Color color, float scale = 1, string name = "Sprite GameObject")
            : base(name)
        {
            base.RelativePosition = position;
            base.color = color;
            base.texture = texture;
            this.scale = scale;
            //base.Height = (int)(texture.Height * scale);
            //base.Width = (int)(texture.Width * scale);

            this.rotation = 0;
            this.spriteEffects = SpriteEffects.None;
            this.layerDepth = 0;
            this.origin = new Vector2(texture.Width, texture.Height) / 2;
        }
        #endregion

        #region Properties
        public Vector2 Origin { get { return origin; } set { origin = value; } }
        public float Rotation { get { return rotation; } set { rotation = value; } }
        public float Scale { get { return scale; } set { scale = value; } }
        public int Width { get { return (int)(texture.Width*scale); } }
        public int Height { get { return (int)(texture.Height*scale); } }
        #endregion
    }
}
